<template>
  <cjui-dialog :model-value="visible" title="弹框标题" @open="open" @close="close" @closed="closed">
    <Parser v-if="visible" v-model="formData" :formConfig="formConfig" />

    <template #footer>
      <el-button type="primary" @click="confirm">
        确定
      </el-button>
      <el-button @click="close">
        取消
      </el-button>
    </template>
  </cjui-dialog>
</template>

<script lang="ts" setup>
import { FormConfigSubmit } from './types'
import Parser from './parser.vue';

interface Props {
  visible: boolean
  formConfig: FormConfigSubmit | undefined
}
withDefaults(defineProps<Props>(), {
  visible: false,
  formConfig: undefined
})
const emits = defineEmits(['update:visible'])

const formData = ref({})
function confirm() {
  console.log('formData', formData)
}

function open() {
}

function close() {
  emits('update:visible', false)
}

function closed() {
}
</script>
